import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    redirect: '/all'
  },
  {
    path: '/all',
    name: 'All',
    redirect: '/home',
    component: () => import('@/views/All/index.vue'),
    children: [
      {
        path: '/home',
        name: 'Home',
        component: () => import('@/views/Home/index.vue'),
        meta: {
          title: '小米-首页'
        }
      },
      {
        path: '/sort',
        name: 'Sort',
        component: () => import('@/views/Sort/index.vue'),
        meta: {
          title: '小米-分类'
        }
      },
      {
        path: '/cart',
        name: 'Cart',
        component: () => import('@/views/Cart/index.vue'),
        meta: {
          title: '小米-购物车'
        }
      },
      {
        path: '/user',
        name: 'User',
        component: () => import('@/views/User/index.vue'),
        meta: {
          title: '小米-用户'
        }
      }
    ]
  },
  {
    path: '/login',
    name: 'Login',
    component: () => import('@/views/Login/index.vue'),
    meta: {
      title: '小米-登录'
    }
  }
]

const router = new VueRouter({
  routes
})

export default router
